{include file="public_head" /}

<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}


        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>
                            优惠券记录管理
                        </h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">

                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}</h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <form name="form" id="form" method="get" action="">
                                    <div class="title_left">
                                        <div class="input-group col-md-2 col-sm-3 col-xs-4" style="float: left;">
                                            <select name="status" class="select2_single" style="width: 100%;"
                                                    tabindex="-1">
                                                <option value="0">- 请选择状态 -</option>
                                                <option value="1" {eq name=':input("status")' value='1' }selected{/eq}>未使用</option>
                                                <option value="2" {eq name=':input("status")' value='2' }selected{/eq}>已使用</option>
                                            </select>
                                        </div>
                                        <div class="input-group col-md-1 col-sm-3 col-xs-4" style="float: left;margin: 0 2%;">
                                            <select name="type" class="select2_single" style="width: 100%;"
                                                    tabindex="-1">
                                                <option value="0">- 全部 -</option>
                                                <option value="1" {eq name=':input("type")' value='1' }selected{/eq}>商品优惠券</option>
                                                <option value="2" {eq name=':input("type")' value='2' }selected{/eq}>服务优惠券</option>
                                            </select>
                                        </div>

                                            <div class="col-md-2 col-sm-6 col-xs-12">
                                                <select name="single_id" class="select2_single"
                                                         tabindex="-1" style="width: 100%"
                                                        datatype="*"
                                                        nullmsg="请选择栏目分类！" errormsg="请选择栏目分类！"
                                                > <option value="0">- 全部 -</option>
                                                    {volist name="single" id="item"}
                                                    <option value="{$item.id}" {eq name="$item.level" value="1"}disabled{/eq}
                                                    >
                                                    {neq name="$item.level" value="1"}{:str_repeat('&nbsp&nbsp',$item.level)}{/neq}|{:str_repeat('--',$item.level)}{$item.cat_name}
                                                    </option>
                                                    {/volist}
                                                </select>
                                            </div>
                                        <div class="input-group" style="float: left;margin: 0 20px; position: relative;z-index: 10000">
                                            <input type="text" class="form-control" name="interval_timer"
                                                   id="interval_timer"
                                                   style="width: 200px;"
                                                   placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                        </div>

                                        <div class="col-md-2 col-sm-3 col-xs-3 form-group pull-left top_search">

                                            <div class="input-group">
                                                <input type="text" class="form-control" name="title"
                                                       placeholder="输入搜索内容..." value="{:input('title')}">
                                            </div>

                                        </div>
                                        <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                                    </div>

                                    <table class="table table-striped table-bordered">
                                        <thead>
                                        <tr class="success">
                                            <th>ID</th>
                                            <th>优惠券ID</th>
                                            <th>会员账号</th>

                                            <th>优惠券类型</th>
                                            <th>服务类型</th>
                                            <th>优惠券标题</th>
                                            <th>优惠券实际金额（满减金额）</th>
                                            <th>优惠券限制时间</th>
                                            <th>使用状态</th>
                                            <th>领取时间</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>
                                        {empty name="data"}
                                        <tr><td colspan="8"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                        {/empty}
                                        {volist name="data" id="item"}
                                        <tr>
                                            <td>{$item.id}</td>
                                            <td>{$item.coupon_id}</td>
                                            <td align="center">
                                                {$item.username}
                                            </td>
                                            <td>{$item.type}</td>
                                            <td>{$item.single_id}</td>
                                            <td>{$item.title}</td>
                                            <td>{$item.minus_price}（{$item.total_price}）</td>
                                            <td>{:date('Y-m-d',$item.start_time)} 至 {:date('Y-m-d',$item.end_time)}</td>
                                            <td>{switch name="$item.status"}
                                                {case 1}未使用{/case}
                                                {case 2}已使用{/case}
                                                {/switch}
                                                </td>
                                            <td>{$item.create_time|date='Y-m-d H:i:s',###}</td>
                                            <td class="operate">
                                                <div>
                                                    <a href="{:url('update', ['id' => $item['id']])}"
                                                       class="label label-primary">
                                                        <span class="fa fa-pencil"></span>&nbsp;&nbsp;编 辑
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                        {/volist}
                                        </tbody>
                                    </table>
                                    <!-- 分页 -->
                                    <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                                    <button type="button" class="btn btn-info" style="margin-top: 20px;" onclick="dc({:input('coupon_id')})">导出优惠券记录</button>
                                </form>
                            </div>
                        </div>
                    </div>

                </div>


            </div>

        </div>
        <!-- /page content -->
    </div>

</div>

{include file="public_foot" /}
<script src="__STATIC__/js/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>

<script type="text/javascript">
    // list
    $(document).ready(function () {
        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
    });

    // 优惠券统计
    $(document).ready(function(){
        var options = {
            legend: false,
            responsive: false
        };

    });
    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
        });

</script>
<script>


</script>
<script>
    function dc(){
        var status = {:input('status',0)};
        var title = "{:input('title')}";
        var type = "{:input('type')}";
        var single_id = "{:input('single_id')}";

        window.location.href = "{:url('console/member_coupon/export')}?status="+status+"&title="+title+"&type="+type+"&single_id"+single_id;
    }
</script>